package com.biz.hunter.dao;

import com.biz.hunter.db.entity.SchPerson;
import com.biz.hunter.dbutil.BaseDAO;
import org.springframework.stereotype.Repository;



@Repository
public class SchPersonDAO {

	private final static String SQL_UPDATE = "update sch_person set name=?,sex=?,mobile=?,birthDay=?,"
			+ "idCard=?,liveIn=?,school=?,specialty=?,highestDegree=?,graduateDate=?,returnee=?,"
			+ "exceptDomain=?,exceptCompany1=?,exceptCompany2=?,exceptCompany3=?,exceptCity=?,"
			+ "updateTime=now() where id = ?";
	public void update(SchPerson schPerson) {
		// TODO Auto-generated method stub
		BaseDAO.execute(SQL_UPDATE, schPerson.getName(),schPerson.getSex(),schPerson.getMobile(),
				schPerson.getBirthDay(),schPerson.getIdCard(),schPerson.getLiveIn(),schPerson.getSchool(),
				schPerson.getSpecialty(),schPerson.getHighestDegree(),schPerson.getGraduateDate(),
				schPerson.getReturnee(),schPerson.getExceptDomain(),schPerson.getExceptCompany1(),
				schPerson.getExceptCompany2(),schPerson.getExceptCompany3(),schPerson.getExceptCity(),
				schPerson.getId());
	}

	private final static String SQL_GETBYID = "select * from sch_person where id =?";
	public SchPerson getById(String id) {
		// TODO Auto-generated method stub
		return BaseDAO.queryForObject(SchPerson.class, SQL_GETBYID, id);
	}

	private final static String SQL_INSERT = "insert sch_person (id,name,sex,mobile,birthday,idCard,"
			+ "liveIn,school,specialty,highestDegree,graduateDate,returnee,exceptDomain,exceptCompany1,"
			+ "exceptCompany2,exceptCompany3,exceptCity,createTime,updateTime) values (?,?,?,?,?,?,?,?,?,"
			+ "?,?,?,?,?,?,?,?,?,now(),now())";
	public void insert(SchPerson schPerson) {
		// TODO Auto-generated method stub
		BaseDAO.execute(SQL_INSERT, schPerson.getId(),schPerson.getUnionid(),schPerson.getName(),schPerson.getSex(),
				schPerson.getMobile(),
				schPerson.getBirthDay(),schPerson.getIdCard(),schPerson.getLiveIn(),schPerson.getSchool(),
				schPerson.getSpecialty(),schPerson.getHighestDegree(),schPerson.getGraduateDate(),schPerson.getReturnee(),
				schPerson.getExceptDomain(),schPerson.getExceptCompany1(),schPerson.getExceptCompany2(),
				schPerson.getExceptCompany3(),schPerson.getExceptCity());
	}
	
	private final static String SQL_GETBYUNIONID = "select * from sch_person where unionid =?";
	public SchPerson getByUnionid(String unionid) {
		// TODO Auto-generated method stub
		return BaseDAO.queryForObject(SchPerson.class, SQL_GETBYUNIONID, unionid);
	}
	

}
